<?php


namespace Admin\Model;

use Think\Model;

class RoleModel extends Model{
    protected $tableName = "role";

    public function lists(){
        $res = M("role")
            ->select();
        if(false !== $res){
            return $res;
        }
    }
     
    public function Find($id){
        $res = M("role")
            ->where("id='$id'")    
            ->find(); 
        if(false !== $res){
            return $res;
        }
    }
    
    public function permissionFind($id){
        $res = M("role_permission")
            ->where("role_id='$id'")
            ->field(permission_id)    
            ->select(); 
        if(false !== $res){
            return $res;
        }
    } 
    public function permissioninfo(){
        $res =M("permission")   
            ->select();
        if(false !== $res){
            return $res;
        }
    }
    
    public function addList($data){
        return $this->add($data);
    } 
    
    public function deleteList($id){
        if(!$id)return;
       ;
        M("role_permission")->where("role_id='$id'")->delete();
        return $this->delete($id);
    }

  


}